var express = require('express')
var router = express.Router()
const { getALL, getOne, exec } = require('../../db')

// 新增事件
router.post('/', async (req, res) => {
  // 用户ID由前台发送过来,还没弄好先写一个固定ID
  console.log(req.body)

  const { id, address, describe, select, mark } = req.body

  let sql = `INSERT INTO event ( user_id,event_type,event_address,event_mark ,event_describe ) VALUES ('${id}','${select}','${address}','${mark}','${describe}')`
  console.log(sql)

  try {
    await exec(sql)
    res.send({
      code: '200',
      msg: '报告事件成功',
    })
  } catch {
    res.send({
      code: '400',
      msg: '报告事件失败',
    })
  }
})

module.exports = router
